<layout name="layout"/>

<!-- 搜索 -->
<div class="form-div search_form_div">
    <form action="__ACTION__" method="GET" name="search_form">

        <p>
            资源名称：
            <input type="text" name="name" size="30" value="<?php echo I('get.name'); ?>"/>
        </p>
        <p>
            资源类型：
            <?php  $type=I('get.sptype');?>
            <select name="sptype" class="input w35" id="">
                <option value="">视频类型</option>
                <foreach name="sptypedata" item="v">
                    <option value="{$v['id']}">{$v['name']}</option>
                </foreach>
            </select>
        </p>
        <p><input type="submit" value=" 搜索 " class="button"/></p>
    </form>
</div>
<!--添加短连接按钮-->
<div class="form-div search_form_div" style="float: right; margin-right: 100px;">

    <p><input id="goadd" type="button" value=" 添加短连接 " class="button"/></p>

</div>
<!-- 列表 -->
<div class="list-div" id="listDiv">
    <table class="table table-hover text-center">
        <tr>
            <th>资源名称</th>
            <th>视频类型</th>
            <th>打赏金额</th>
            <th>发布者id</th>
            <th>视频缩略图</th>
            <th>是否开启随机</th>
            <th>唯一标识</th>
            <th>看片模式</th>
            <th>发布时间</th>
            <th width="300">操作</th>
        </tr>
        <?php foreach ($data as $k => $v): ?>
        <tr class="tron">
            <td><?php echo $v['name']; ?></td>
            <td><?php echo $v['typename']; ?></td>
            <td><?php echo $v['money'].'~'.$v['sj']; ?></td>
            <td><?php echo $v['userid']; ?></td>
            <td><?php showImage($v['smallpic'],50,50);?></td>
            <td><?php if($v['sj']==1){echo '否';}else{echo '是';}; ?></td>
            <td><?php echo $v['zykey']; ?></td>
            <td><?php if($v['allow']==1){echo '单片观看';}elseif($v['allow']==2){echo '会员观看';}else{echo '两者皆有';} ?></td>
            <td><?php echo date('Y-m-d H:i:s',$v['time']); ?></td>
            <td align="center">
                <a href="<?php echo U('edit?id='.$v['id'].'&p='.I('get.p')); ?>" title="编辑"
                   class="button border-main" style="cursor: pointer"><span class="icon-edit"></span>编辑</a>
                <a class="button border-red del" style="cursor: pointer" onclick="del(this)"
                   url="<?php echo U('delete?id='.$v['id'].'&p='.I('get.p')); ?>"
                   title="移除"> <span class="icon-trash-o"></span>移除</a>
            </td>
        </tr>
        <?php endforeach; ?>
        <?php if(preg_match('/\d/', $page)): ?>
        <tr>
            <td colspan="10">
                <?php echo $page; ?>
            </td>
        </tr>
        <?php endif; ?>
    </table>
</div>
<script>
    function del(obj) {
        if (confirm('确认删除吗？')) {
            $.get($(obj).attr('url'), function (res) {
                alert(res.info);
                location.href = res.url;
            })
        }
    }

    $("#goadd").click(function () {
        location.href = "<?php echo U('tglink/add')?>";
    })

    function play(url) {
        layer.alert('<video preload="auto"  controls style="width:580px;height:430px;margin-top:-65px;"><source src="' + url + '" type="video/mp4"><ideo>', {
            skin: 'layui-layer-molv',
            area: ['620px', '510px']
            , closeBtn: 0, btn: ['关闭'],
            title: "视频预览",
        });
    }

</script>